package com.lagou.edu.utils;

import com.alibaba.druid.pool.DruidDataSource;

/**
 * @author 应癫
 */
public class DruidUtils {
    
    private static final String JDBC_FILE_NAME = "jdbc.properties";
    
    private DruidUtils()
    {}
    
    private static DruidDataSource druidDataSource = new DruidDataSource();
    
    static
    {
        String driverClassName = PropertiesUtil.getPropertyValue(JDBC_FILE_NAME, "jdbc.driver");
        druidDataSource.setDriverClassName(driverClassName);
        String url = PropertiesUtil.getPropertyValue(JDBC_FILE_NAME, "jdbc.url");
        druidDataSource.setUrl(url);
        String username = PropertiesUtil.getPropertyValue(JDBC_FILE_NAME, "jdbc.username");
        druidDataSource.setUsername(username);
        String password = PropertiesUtil.getPropertyValue(JDBC_FILE_NAME, "jdbc.password");
        druidDataSource.setPassword(password);
    }
    
    public static DruidDataSource getInstance()
    {
        return druidDataSource;
    }
    
}
